package com.bsoft.gol.hcs.clinical.dao;

import ctd.persistence.annotation.DAOMethod;
import ctd.persistence.annotation.DAOParam;
import ctd.persistence.support.hibernate.HibernateSupportDelegateDAO;
import com.bsoft.gol.hcs.clinical.entity.OdsCommonPrescriptionDrug;

import java.util.List;

public abstract class OdsCommonPrescriptionDrugDAO extends HibernateSupportDelegateDAO<OdsCommonPrescriptionDrug> {
    public OdsCommonPrescriptionDrugDAO() {
        this.setKeyField("prescriptionDrugId");
    }

    @DAOMethod(sql = "from OdsCommonPrescriptionDrug where commonPrescriptionInfoId in(:commonPrescriptionInfoIds)")
    public abstract List<OdsCommonPrescriptionDrug> findByCommonPrescriptionInfoIds(@DAOParam("commonPrescriptionInfoIds") List<String> commonPrescriptionInfoIds);

    @DAOMethod(sql = "from OdsCommonPrescriptionDrug where commonPrescriptionInfoId =:commonPrescriptionInfoId ")
    public abstract List<OdsCommonPrescriptionDrug> findByCommonPrescriptionInfoId(@DAOParam("commonPrescriptionInfoId") String commonPrescriptionInfoId);

    @DAOMethod(sql = "from OdsCommonPrescriptionDrug where commonPrescriptionInfoId =:commonPrescriptionInfoId and orgDrugId=:orgDrugId and orgId=:orgId")
    public abstract List<OdsCommonPrescriptionDrug> queryExistPrescriptionDrug(@DAOParam("commonPrescriptionInfoId")String commonPrescriptionInfoId,
                                                                         @DAOParam("orgDrugId")String orgDrugId,
                                                                         @DAOParam("orgId")String orgId);

    @DAOMethod(sql = "delete from OdsCommonPrescriptionDrug where prescriptionDrugId in(:prescriptionDrugIds)")
    public abstract void deleteOdsPrescriptionDrugByIds(@DAOParam("prescriptionDrugIds") List<String> prescriptionDrugIds);

    @DAOMethod(sql = "delete from OdsCommonPrescriptionDrug where prescriptionDrugId=:prescriptionDrugId")
    public abstract void deleteOdsPrescriptionDrugById(@DAOParam("prescriptionDrugId") String prescriptionDrugId);

}